<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript"
	src="${ctx}/resources/js/datatable-query.js"></script>
  <style type="text/css">

    .table-bordered th, .table-bordered td {
        white-space: pre-line;
        word-wrap : break-word;
        word-break:break-all;
     }

    </style>
<div class="row-fluid">
<div class="span12">
<div class="box">
<div class="blue title">
<h4><span>Search</span></h4>
<a href="#" class="minimize">Minimize</a></div>
<div class="content">
<form id="uploadForm" enctype="multipart/form-data">
<div class="form-row row-fluid">
<div class="span6">
<div class="row-fluid"><label class="form-label span4"
	for="textarea">Post Title :</label>
<div class="span4 controls" id="currencyPair"><select
	name="encoding" class="filterdata" op="eq" field="categoryPost.id">
	<c:set var="allEntity" value="${requestScope.categoryPosts}" />
	<c:if test="${allEntity!=null}">
		<option value="">--ALL--</option>
		<c:forEach var="entity" items="${allEntity}">
			<option value="${entity.id}" ${(entity.id==postId)?'selected':''}  > ${entity.title}</option>
		</c:forEach>
	</c:if>
</select></div>

</div>
</div>

<div class="span6">
<div class="row-fluid"><label class="form-label span4"
	for="textarea">Pending :</label>
<div class="span4"><input type="checkbox" ${(pending !=null)?
	'checked="checked" ':''}     field="status" op="eq" value="PENDING"
	class="filterdata"></div>

</div>
</div>


</div>
</form>
</div>
</div>
</div>
</div>

<div class="row-fluid">
<div class="span12">
<div class="box gradient">
<div class="title">
<h4 class="button-bar"><span >Comment </span></h4>
<a href="#" class="minimize">Minimize</a></div>
<div class="content scrollable clearfix">
<table class="ajaxTable display table table-bordered">
	<thead>
		<tr>
			<th><a id="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
			<th>Post Title</th>
		<th>Author </th>
		<th>Email </th>
		<th>Content </th>
		<th>Create Date </th>
		<th>Status </th>
		<th>Action</th>
		</tr>
	</thead>
</table>
</div>
</div>
 </div>
 </div>

<script type="text/javascript">

var render = false;
var oTime = "";
$(document).ready(function () {
 	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs": [
		  { 'bSortable': false, 'aTargets': [0,4] }
		],
		"sAjaxSource": '${ctx}/admin/category-post-comment/',
		"fnInitComplete": function (oSettings, json) { }
	});

	
	johnny.resetFilter($('.reset'));

 

	$(".filterdata").change(function () {
		updateGrid();
	});
	
	var approve = {
			id : 'approve',
			text  : 'Approve',
			domain : "comment",
			operation : "approve",
			url : "${ctx}/admin/category-post-comment/approve/"
	};
	johnny.tableBtn(approve);
	
	
	var reject = {
			id : 'reject',
			text  : 'Reject',
			domain : "comment",
			operation : "reject",
			url : "${ctx}/admin/category-post-comment/reject/"
	};
	johnny.tableBtn(reject);	
	
	
	
	
 });
function updateGrid() {
	window.clearTimeout(oTime);
	oTime = setTimeout(function () { johnny.oTable.fnDraw(); }, 500);
}

var columnHeader = ['','categoryPost.title','name','email', '', 'createDate','status'];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}
 
var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var link = "${ctx}/admin/category-post-comment/"+json.result[i].id+"/edit/";
 		subArray.push(johnny.getForSelect(json.result[i].id));
 		subArray.push(json.result[i].categoryPost.title);
		subArray.push(json.result[i].name);
		subArray.push(json.result[i].email)
		subArray.push(contentHtml(json.result[i].commentContent));
  		subArray.push(json.result[i].createDate);
		subArray.push(json.result[i].status)
		subArray.push(johnny.getEditHtml(link));
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}

function contentHtml(content){
 
	 var mainSpan = $("<span>");
	    $("<p>").addClass("span12 styled").attr({
 	        readonly : "readonly"
 	 	        
	    }).text(content).appendTo(mainSpan);
	    return mainSpan.html();

	
}

</script>
<body>